package com.plian.system.controller.sys.announcements;

import com.plian.Tools.pagedata.PageData;
import com.plian.system.annotation.Behavioral;
import com.plian.system.model.ListResult;
import com.plian.system.model.ObjResult;
import com.plian.system.service.sys.announcements.AnnouncementsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "api/announcements")
public class AnnouncementsController {
    @Autowired
    AnnouncementsService announcementsService;
    @PostMapping(value = "/save")
    public ObjResult save(@RequestBody PageData pd) throws Exception {
        //参数userName，passWord
        return announcementsService.save(pd);
    }
    @PostMapping(value = "/edit")
    public ObjResult edit(@RequestBody PageData pd) throws Exception {
        return announcementsService.edit(pd);
    }

    /**
     * 根据id查询
     * @param pd
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/findid")
    @Behavioral(formType = "238",actionTypeId = "1")
    public ObjResult detail(@RequestBody PageData pd) throws Exception {
        return announcementsService.findid(pd);
    }
    @PostMapping(value = "/del_ids")
    public ObjResult del_ids(@RequestBody PageData pd) throws Exception {
        return announcementsService.del_ids(pd);
    }
    /**
     * 查询列表
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/list")
    public ListResult listpage(@RequestBody PageData pd) throws Exception {
        return announcementsService.listPage(pd);
    }
    @PostMapping(value = "/ChagPublishAll")
    public ObjResult ChagPublishAll(@RequestBody PageData pd) throws Exception {
        return announcementsService.ChagPublishAll(pd);
    }
    @PostMapping(value = "/ChagtopAll")
    public ObjResult ChagtopAll(@RequestBody PageData pd) throws Exception {
        return announcementsService.ChagtopAll(pd);
    }
}
